package co.edu.javeriana.monopoly.client.images;



import java.awt.BorderLayout;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

import co.edu.javeriana.monopoly.model.IPropiedad;

public class PropiedadPanel extends JPanel {
	public final static int INVERSEHORIZONTAL = 4;
	public final static int INVERSEVERTICAL = 2; 
	public final static int HORIZONTAL = 3; 
	public final static int VERTICAL = 1;
	/**
	 * 
	 */
	private static final long serialVersionUID = -2789132931441891056L;
	private int direction;
	private int height;
	private JLabel imagen;
	private IPropiedad propiedad;
	private JLabel text;
	private int width;
	private JPanel zone;
	
	/**
	 * Constructor
	 *
	 */
	public PropiedadPanel ( IPropiedad propiedad, int width, int height, int direction ) {
		super ( );
		setWidth ( width );
		setHeight ( height );
		setPropiedad ( propiedad );
		setDirection ( direction );
		init ( );
	}

	public int getDirection ( ) {
		return direction;
	}

	public int getHeight ( ) {
		return height;
	}

	public IPropiedad getPropiedad ( ) {
		return propiedad;
	}

	public int getWidth ( ) {
		return width;
	}

	public void init ( ) {
		this.setBorder ( BorderFactory.createLineBorder ( new java.awt.Color ( 0, 0, 0 ) ) );
		zone = new JPanel ( );
		zone.setBackground ( propiedad.getZone ( ) ); 
        zone.setSize ( width, height / 5 );
        text = new JLabel ( );
        text.setHorizontalAlignment ( SwingConstants.CENTER );
        text.setText ( propiedad.getNombre ( ) );
        text.setSize ( width, height / 5 );
        imagen = new JLabel ( );
        imagen.setIcon ( new ImageIcon  ( getClass ( ).getResource ( "/co/edu/javeriana/monopoly/client/images/Transmilenio.gif" ) ) );
        imagen.setSize ( width, height / 5 * 3 );
		/*switch ( direction ) {
			case PropiedadComponent.HORIZONTAL : 
		        zoneLayout.setHorizontalGroup ( zoneLayout.createParallelGroup ( GroupLayout.Alignment.LEADING ).addGap ( 0, height, Short.MAX_VALUE ) );
		        zoneLayout.setVerticalGroup ( zoneLayout.createParallelGroup ( GroupLayout.Alignment.LEADING ).addGap ( 0, width / 10, Short.MAX_VALUE ) );
				break;
			case PropiedadComponent.INVERSEHORIZONTAL : 
		        zoneLayout.setHorizontalGroup ( zoneLayout.createParallelGroup ( GroupLayout.Alignment.LEADING ).addGap ( 0, height, Short.MAX_VALUE ) );
		        zoneLayout.setVerticalGroup ( zoneLayout.createParallelGroup ( GroupLayout.Alignment.LEADING ).addGap ( 0, height, Short.MAX_VALUE ) );
				break;
			case PropiedadComponent.VERTICAL:
		        zoneLayout.setHorizontalGroup ( zoneLayout.createParallelGroup ( GroupLayout.Alignment.LEADING ).addGap ( 0, width, Short.MAX_VALUE ) );
		        zoneLayout.setVerticalGroup ( zoneLayout.createParallelGroup ( GroupLayout.Alignment.LEADING ).addGap ( 0, height, Short.MAX_VALUE ) );
				break;
			case PropiedadComponent.INVERSEVERTICAL : 
				break;			
		}*/
        this.setLayout ( new BorderLayout ( ) );
		this.add ( zone, BorderLayout.NORTH );
		this.add ( imagen, BorderLayout.CENTER );
		this.add ( text, BorderLayout.SOUTH );
		
	}

	public void setDirection ( int direction ) {
		this.direction = direction;
	}

	public void setHeight ( int height ) {
		this.height = height;
	}
	public void setPropiedad ( IPropiedad propiedad ) {
		this.propiedad = propiedad;
	}
	
	public void setWidth ( int width ) {
		this.width = width;
	}

}
